home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- //
- // Creation Date: 2001
- // Author: lf
- //
- // Procedure Name:
- // setNotesAttribute
- //
- // Input Value:
- // Node name, attribute names and type, and new attribute value
- //
- // Output Value:
- // None
- //
-
- global proc setNotesAttribute(
- string $nodeName,
- string $longAttrName, string $shortAttrName, string $attrType,
- string $newAttrValue )
- {
- if( !`objExists $nodeName` ) {
- return;
- }
- // Description: Sets the given "Notes" attribute on the node
- // to be the new value. If the attribute doesn't exist,
- // then create it as a dynamic attribute, and set it.
-
- // Warning! $newAttrValue is not really used here even though
- // it's passed in. It's checked a few times, but ultimately
- // `scrollField -q -text AENotesScrollFIeld` is used.
- // If you replace the scrollField query to use $newAttrValue
- // (which is the proper way to do things), then multi-line
- // entry into the notes area behaves strangely and
- // doesn't preserve carriage returns.
-
- // If the Notes attribute exists, then just update it
- // If the newAttrValue attribute is empty, that means
- // that this attribute is to be deleted.
- //
- if( `attributeQuery -exists -n $nodeName $longAttrName` ) {
- if( !`getAttr -lock ($nodeName + "." + $longAttrName)`) {
-
-
- if( size($newAttrValue) > 0 ) {
- // Update the Notes only if it's changed
- string $currentNotes = `getAttr ($nodeName + "." + $longAttrName)`;
- if( $currentNotes != $newAttrValue ) {
- $editCmd = ("setAttr " + "-type \"" + $attrType + "\" "
- + $nodeName + "." + $longAttrName +
- " `scrollField -q -text AENotesScrollField`");
- if( catch( eval($editCmd)) ) {
- error(" Could not set attribute: " + $nodeName + "." + $longAttrName);
- }
- }
- } else {
- // Delete this attribute from the node
- // but only if the attribute is a dynamic one
- //
- string $dynamicAttrs[] = `deleteAttr -q $nodeName`;
- int $i;
- int $numAttrs = size($dynamicAttrs);
- for( $i = 0; $i < $numAttrs; $i ++ ) {
- if( $dynamicAttrs[$i] == $longAttrName ) {
- if( catch( deleteAttr ($nodeName + "." + $longAttrName)))
- {
- // Problem deleting attribute,
- // possibly because a script job still refers
- // to this attribute
- warning("Could not delete the notes attribute. Make sure the Extra Attributes section in the Attribute Editor is closed.");
- }
- break;
- }
- }
- }
- }
-
- } else {
-
- // If the Notes attribute doesn't exist, then create it and set it
- //
- if( size($newAttrValue) > 0 ) {
- if( catch(`addAttr -dt $attrType -ln $longAttrName
- -sn $shortAttrName $nodeName`) )
- {
- error(" Could not create dynamic attribute: "
- + $nodeName + "." + $longAttrName + " (long name), "
- + $nodeName + "." + $shortAttrName + " (short name) ");
- } else {
-
- // Do same as above and update the Notes attr
- //
- $editCmd = ("setAttr " + "-type \"" + $attrType + "\" "
- + $nodeName + "." + $longAttrName +
- " `scrollField -q -text AENotesScrollField`");
- if( catch( eval($editCmd)) ) {
- error(" Could not set attribute: " + $nodeName + "." + $longAttrName);
- }
- }
- }
- }
- }
-
-